////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                           BailterRay                                       //
//                    Pip Robbins & Zhao Zhang                                //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
class BailterRaySpringPad extends NavigationPoint
      placeable;

var SoundCue JumpSound;
var MeshComponent PuffBallMesh;
var ParticleSystemComponent PuffEffect;

event PostBeginPlay() {

        if (PuffEffect != None)
    	{
    		SkeletalMeshComponent(PuffBallMesh).AttachComponentToSocket(PuffEffect, 'PuffSocket');
    	}
}

event Touch( Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal )
{
	if ( (UTPawn(Other) == None) || (Other.Physics == PHYS_None) || UTPawn(Other).IsHero() )
		return;

	PendingTouch = Other.PendingTouch;
	Other.PendingTouch = self;
}

event PostTouch(Actor Other)
{
	local BailterRayPawn P;
    local BailterRayPlayerController PC;

	P = BailterRayPawn(Other);
	if (P == None || P.Physics == PHYS_None || P.DrivenVehicle != None)
	{
		return;
	}
    if(P.IsHumanControlled())
    {
        PC = BailterRayPlayerController(P.Controller);
    }

    // Makes player jump 1.4 higher then before.
    if(P.MultiJumpRemaining >= 0)
    {
        P.MultiJumpRemaining = -1;
	    P.Velocity.Z = (PC.maxJumpVelocity * 1.4);

	    if (SkeletalMeshComponent(PuffBallMesh) != None)
	    {
	        PuffEffect.SetActive(true);
		    SkeletalMeshComponent(PuffBallMesh).PlayAnim('PuffMove', SkeletalMeshComponent(PuffBallMesh).GetAnimLength('PuffMove'), false);
        }
    }
    else
    {
        P.Velocity.Z = PC.maxJumpVelocity;
        if (SkeletalMeshComponent(PuffBallMesh) != None)
	    {
	        PuffEffect.SetActive(true);
		    SkeletalMeshComponent(PuffBallMesh).PlayAnim('PuffMove', SkeletalMeshComponent(PuffBallMesh).GetAnimLength('PuffMove'), false);
        }
    }

	if ( JumpSound != None )
		P.PlaySound(JumpSound);
}

DefaultProperties
{
   JumpSound=SoundCue'A_Gameplay.JumpPad.Cue.A_Gameplay_JumpPad_Activate_Cue'
   bBlockedForVehicles=True
   Begin Object name=CollisionCylinder ObjName=CollisionCylinder Archetype=CylinderComponent'Engine.Default__NavigationPoint:CollisionCylinder'
      CollideActors=True
      ObjectArchetype=CylinderComponent'Engine.Default__NavigationPoint:CollisionCylinder'
      Translation = (X = 0, Y  = 0, Z = -30);
   End Object
   CylinderComponent=CollisionCylinder
   GoodSprite=None
   BadSprite=None
   Begin Object class=ParticleSystemComponent Name=PuffSmoke ObjName=PuffSmoke Archetype=ParticleSystemComponent'Engine.Default__ParticleSystemComponent'
      Template=ParticleSystem'BailterRayAssetPackage.Effects.PuffBallSmoke'
      Translation = (X = 0, Y  = 0, Z = 125);
      scale = 1.1
      name="PuffSmoke"
      ObjectArchetype=ParticleSystemComponent'Engine.Default__ParticleSystemComponent'
   End Object
   PuffEffect=PuffSmoke
   Begin Object class=SkeletalMeshComponent Name=PuffBall
      SkeletalMesh=SkeletalMesh'BailterRayAssetPackage.PuffJoint'
      Begin Object class=AnimNodeSequence Name=MeshSequence ObjName=MeshSequence Archetype=AnimNodeSequence'Engine.Default__AnimNodeSequence'
         name="MeshSequence"
         ObjectArchetype=AnimNodeSequence'Engine.Default__AnimNodeSequence'
      End Object
      Animations=AnimNodeSequence'BailterRay.Default__BailterRaySpringPad:PuffBall.MeshSequence'
      AnimSets(0)=AnimSet'BailterRayAssetPackage.PuffAnimSet'
      Translation = (X = 0, Y  = 0, Z = -80);
      name="PuffBall"
   End Object
   Components(4)=PuffBall
   PuffBallMesh=PuffBall
   bStatic=False
   bMovable=False
   bCollideActors=True
   CollisionComponent=CollisionCylinder
   CollisionType=COLLIDE_CustomDefault
   name="Default__BailterRaySpringPad"
   ObjectArchetype=NavigationPoint'Engine.Default__NavigationPoint'
}